//
//  WJTabBarVC.m
//  WJBSApp
//
//  Created by dllo on 16/7/14.
//  Copyright © 2016年 王景伟. All rights reserved.
//
//  UITabBarController 里面有tabbar
//  1. 在 UITabBarController 创建自定义的Button就可以实现自定义
//     在APPdelegate 里面设置控制器  不可以我要在这里添加控制器
//     写完button给button添加方法persent和push navc  这样写太麻烦了
//  3. 直接用系统给的 这样写有一个问题是夜间模式变色问题-->改变Bar的颜色

#import "WJTabBarVC.h"
#import "WJ_Essence_VC.h"
#import "WJ_New_VC.h"
#import "WJ_Publish_VC.h"
#import "WJ_Follow_VC.h"
#import "WJTabBar.h"

@interface WJTabBarVC ()<UITabBarControllerDelegate>

@end

@implementation WJTabBarVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    // 添加子控制器
    [self addChildViewController];
    
    // 直接覆盖了原有的tabbar 基类也不管用了 无法使用夜间模式
    [self setValue:[[WJTabBar alloc]init] forKey:@"tabBar"];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

- (void)addChildViewController
{
    //精华
    [self addOneChildViewController:[[WJ_Essence_VC alloc]init] title:@"精华" image:@"tabBar_essence_icon@3x副本" selected:@"tabBar_essence_click_icon@3x副本.png"];
    
    
    //最新
    [self addOneChildViewController:[[WJ_New_VC alloc]init] title:@"最新" image:@"tabBar_new_icon@3x副本.png" selected:@"tabBar_new_click_icon@3x副本.png"];
    
    
    //关注
    [self addOneChildViewController:[[WJ_Follow_VC alloc]init] title:@"关注" image:@"tabBar_friendTrends_icon@3x副本" selected:@"tabBar_friendTrends_click_icon@3x副本.png"];
    
    //我
    [self addOneChildViewController:[[WJ_Essence_VC alloc]init] title:@"我" image:@"tabBar_me_icon@3x副本" selected:@"tabBar_me_click_icon@3x副本.png"];
    
    
}

//设置公用控制器
- (void)addOneChildViewController:(UIViewController *)vc title:(NSString *)title image:(NSString *)image selected:(NSString *)selecetedImage
{
    vc.tabBarItem.title = title;
    vc.tabBarItem.image = [UIImage imageNamed:image];
    vc.tabBarItem.selectedImage = [UIImage imageNamed:selecetedImage];
    //自定义NavigationViewController用来改变夜间模式
    WJBaseNavigationController *nav = [[WJBaseNavigationController alloc]initWithRootViewController:vc];
    [self addChildViewController:nav];
}



@end
